package com.sdb.docter.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdb.common.annotation.Log;
import com.sdb.common.core.controller.BaseController;
import com.sdb.common.core.domain.AjaxResult;
import com.sdb.common.enums.BusinessType;
import com.sdb.docter.domain.Docter;
import com.sdb.docter.service.IDocterService;
import com.sdb.common.utils.poi.ExcelUtil;
import com.sdb.common.core.page.TableDataInfo;

/**
 * 医生管理Controller
 * 
 * @author yyh
 * @date 2024-11-19
 */
@RestController
@RequestMapping("/docter/docter")
public class DocterController extends BaseController
{
    @Autowired
    private IDocterService docterService;

    /**
     * 查询医生管理列表
     */
    @PreAuthorize("@ss.hasPermi('docter:docter:list')")
    @GetMapping("/list")
    public TableDataInfo list(Docter docter)
    {
        startPage();
        List<Docter> list = docterService.selectDocterList(docter);
        return getDataTable(list);
    }

    /**
     * 导出医生管理列表
     */
    @PreAuthorize("@ss.hasPermi('docter:docter:export')")
    @Log(title = "医生管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Docter docter)
    {
        List<Docter> list = docterService.selectDocterList(docter);
        ExcelUtil<Docter> util = new ExcelUtil<Docter>(Docter.class);
        util.exportExcel(response, list, "医生管理数据");
    }

    /**
     * 获取医生管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('docter:docter:query')")
    @GetMapping(value = "/{dcId}")
    public AjaxResult getInfo(@PathVariable("dcId") Long dcId)
    {
        return success(docterService.selectDocterByDcId(dcId));
    }

    /**
     * 新增医生管理
     */
    @PreAuthorize("@ss.hasPermi('docter:docter:add')")
    @Log(title = "医生管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Docter docter)
    {
        return toAjax(docterService.insertDocter(docter));
    }

    /**
     * 修改医生管理
     */
    @PreAuthorize("@ss.hasPermi('docter:docter:edit')")
    @Log(title = "医生管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Docter docter)
    {
        return toAjax(docterService.updateDocter(docter));
    }

    /**
     * 删除医生管理
     */
    @PreAuthorize("@ss.hasPermi('docter:docter:remove')")
    @Log(title = "医生管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dcIds}")
    public AjaxResult remove(@PathVariable Long[] dcIds)
    {
        return toAjax(docterService.deleteDocterByDcIds(dcIds));
    }
}
